package net.niufei.study.cpatterns.producerconsumer;

import net.niufei.study.util.RandUtil;

public class Producer implements Runnable {
	private final Resource resource;
	
	public Producer(Resource resource) {
		this.resource = resource;
	}

	@Override
	public void run() {
		while (true) {
			try {
				Thread.sleep(RandUtil.random.nextInt(1000));
				resource.supply(Thread.currentThread().getName());
			} catch (InterruptedException e) {}
		}
	}
	
}
